package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.OperationRecord;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OperationRecordDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "项目id")
    private Integer projectId;

    @ApiModelProperty(value = "操作时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date operationTime;

    @ApiModelProperty(value = "操作人")
    private Integer adminId;

    @ApiModelProperty(value = "操作人名称")
    private String username;

    @ApiModelProperty(value = "操作描述")
    private String comment;

    @ApiModelProperty(value = "审核备注原因")
    private String remark;


    public OperationRecordDTO() {}

    public OperationRecordDTO(OperationRecord entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static OperationRecordDTO convert(OperationRecord entity) {
        return new OperationRecordDTO(entity);
    }

    public static List<OperationRecordDTO> convertList(List<OperationRecord> list) {
        List<OperationRecordDTO> resultList = new ArrayList<>();
        for (OperationRecord entity : list) {
            resultList.add(new OperationRecordDTO(entity));
        }
        return resultList;
    }}
